package nc.ui.capub.fileparse;

import java.util.ArrayList;

import nc.ui.capub.fileparsedlg.PubFileChoose;
import nc.vo.capub.meta.MetaAggVO;
import nc.vo.capub.meta.MetaVO;

public class ImportTxtParser implements INFTFileParse
{
	private MetaAggVO meta=null;
	
	public ImportTxtParser(MetaAggVO meta)
	{
		this.meta=meta;
	}
	@SuppressWarnings("unchecked")
	public ArrayList getResult() throws Exception
	{
		String filePath = new PubFileChoose().getFilePath();
		if(filePath==null)
			return null;
		ArrayList dataList=this.getFileData(meta, filePath);
		return dataList;
	}
	@SuppressWarnings("unchecked")
	public ArrayList getFileData(MetaAggVO meta,String filePath) throws Exception
	{
		ArrayList<ArrayList> al=new ArrayList<ArrayList>();
		if(meta!=null)
		{
			Object o=meta.getParentVO();
			if(o!=null)
			{
				String splitStr=((MetaVO)o).getSplitstr();
				if(splitStr!=null&&splitStr.trim().length()>0)
					al = ParseFileTool.parseFile(filePath,splitStr);
			}
		}
		return al;
	}
	
}
